<template>
  <div class="page editStore new-form-list">
    <mt-actionsheet :actions="actions"
		                v-model="chooseImgVisible">
		</mt-actionsheet>
    <div class="scroll-view">
      <customHeader :middleTitle="header"  @leftCallBack="handleBack"/>
      <div class="page-body">
        <div class="form-wrapper">
          <mt-field class="border-bt-left" label="主店名" placeholder="例:肯德基" v-model="formData.mainShopName" :attr="{ maxlength: 20}"></mt-field>
          <mt-field label="分门店名" class="border-bt-left" placeholder="非必填，例:上地店" v-model="formData.branchShopName" :attr="{ maxlength: 20}"></mt-field>
          <div class="form-item border-bt-left">
            <div class="label">所属类目</div>
            <div class="pick-value" @click="showPicker('category')">{{categorySplice?categorySplice:category.tip}}
            </div>
            <i class="zhk-list_rarrow"></i>
            <awesome-picker ref="category" :textTitle="category.textTitle" :data="category.data" :anchor="category.anchor" @confirm="(v)=>handleConfirm('category',v,category.data)">
            </awesome-picker>
          </div>
          <mt-field class="border-bt-left" label="门店电话" type="tel" placeholder="请填写门店电话" v-model="formData.contactNumber" :attr="{ maxlength: 11}"></mt-field>
          <div class="form-item border-bt-left">
            <div class="label">门店区域</div>
            <div class="pick-value" @click="storeAreaShow('address')">{{storeAreaName?storeAreaName:"请选择省、市、区(县)"}}
            </div>
            <i class="zhk-list_rarrow"></i>
            <citys-picker :city="dataArea" :init-value="storeAreaDefaultVal" @confirm="storeAreaConfirm" ref="citys"></citys-picker>
          </div>

          <mt-field class="border-bt-left" label="门店地址" placeholder="请填写详细地址" v-model="formData.address" :attr="{ maxlength:32}"></mt-field>
          <mt-field class="border-bt-left" label="门店简介" type="textarea" placeholder="非必填，最多200字" v-model="formData.desc" :attr="{ maxlength:200}"></mt-field>
        </div>
        <div class="form-wrapper">
          <div class="border-bt-all">
            <div class="form-title ">
              门店照片
            </div>
          </div>
          <div  class="store-head ">
            <div class="tt">门头照</div>
            <div  class="ct border-bt">
                <div  class="store-head-box border-dashed" v-if="formData.mainImage.length == 0" @click="chooseImg('mainImage')">
                  <img class="imgOpcity" :src="require('../../assets/images/up_bg_md.png')" />
                  <span class="zhk-sczp"/>
                </div>
                <div class="store-head-box border-solid" v-else-if="formData.mainImage.length > 0" >
                  <img :src="repeatImgUrl(formData.mainImage[0],'resize')" alt="" @click="showImg(formData.mainImage[0])" />
                  <span class="zhk-sbylx" @click="delImage('mainImage')"></span>
                </div>
            </div>
          </div>
          <div  class="store-head ">
            <div class="tt">内景照</div>
            <div  class="ct border-bt">
                <div  class="store-head-box border-dashed" v-if="formData.innerImage.length == 0" @click="chooseImg('innerImage')">
                  <img class="imgOpcity" :src="require('../../assets/images/up_bg_mn.png')" />
                  <span class="zhk-sczp"/>
                </div>
                <div class="store-head-box border-solid" v-else-if="formData.innerImage.length > 0" >
                  <img :src="repeatImgUrl(formData.innerImage[0],'resize')" alt="" @click="showImg(formData.innerImage[0])" />
                  <span class="zhk-sbylx" @click="delImage('innerImage')"></span>
                </div>
            </div>
          </div>
          <div  class="store-head ">
            <div class="tt">收银台照</div>
            <div  class="ct border-bt">
                <div  class="store-head-box border-dashed" v-if="formData.checkoutImage.length == 0" @click="chooseImg('checkoutImage')">
                  <img class="imgOpcity" :src="require('../../assets/images/up_bg_sy.png')" />
                  <span class="zhk-sczp"/>
                </div>
                <div class="store-head-box border-solid" v-else-if="formData.checkoutImage.length > 0" >
                  <img :src="repeatImgUrl(formData.checkoutImage[0],'resize')" alt="" @click="showImg(formData.checkoutImage[0])" />
                  <span class="zhk-sbylx" @click="delImage('checkoutImage')"></span>
                </div>
            </div>
          </div>
        </div>
        <div class="form-wrapper">
          <div class="border-bt-all">
            <div class="form-title ">
              商家资质信息
            </div>
          </div>
          <div class="form-item border-bt-left">
            <div class="label">商户类型</div>
            <div class="pick-value" @click="showPicker('shopType')">{{this.formData.shopType?showIdName(shopType.data,this.formData.shopType):shopType.tip}}
            </div>
            <i class="zhk-list_rarrow"></i>
            <awesome-picker ref="shopType" :textTitle="shopType.textTitle" :data="getAwesomeData(shopType.data)" :anchor="shopType.anchor" @confirm="(v)=>handleConfirm('shopType',v,shopType.data)">
            </awesome-picker>
          </div>
          <div v-if="formData.shopType != '01'">
            <div  class="store-head ">
              <div class="tt">营业执照照片</div>
              <div  class="ct border-bt">
                  <div  class="store-head-box border-dashed" v-if="!formData.businessLicenseImage" @click="chooseImg('businessLicenseImage','baidu_ocr_business_license')">
                    <img class="imgOpcity" :src="require('../../assets/images/up_bg_yy.png')" />
                    <span class="zhk-sczp"/>
                  </div>
                  <div class="store-head-box border-solid" v-else-if="formData.businessLicenseImage" >
                    <img :src="repeatImgUrl(formData.businessLicenseImage,'resize')" alt="" @click="showImg(formData.businessLicenseImage)" />
                    <span class="zhk-sbylx" @click="delImage('businessLicenseImage')"></span>
                  </div>
              </div>
            </div>
          </div>
          <mt-field label="公司全称" placeholder="必须与营业执照登记名称一致" v-model="formData.companyName" :attr="{ maxlength: 64}"></mt-field>
          <div class="cell-explain border-bt">
            <div class="ct">若营业执照名称为空或商户类型为自然人，填写：个体户+负责人名，例：“个体户李雷”</div>
          </div>
          <div v-if="formData.shopType != '01'">
            <mt-field class="border-bt-left" label="营业执照注册地址" placeholder="请填写营业执照工商注册地址" v-model="formData.licenseRegisterAddress" :attr="{ maxlength: 50}"></mt-field>
            <mt-field class="border-bt-left" label="营业执照注册号" placeholder="请填写营业执照工商注册号" v-model="formData.businessLicense" :attr="{ maxlength: 20}"></mt-field>
            <div class="form-item border-bt-left">
              <div class="label">营业执照有效期</div>
              <div class="pick-value" @click="showPeriod('licenseExpireStart')">{{this.formData.licenseExpireStart && this.formData.licenseExpire?this.formData.licenseExpireStart + ' 至 ' + (this.formData.licenseExpire == '29991231'?'长期':this.formData.licenseExpire+'年'):licenseExpireStart.tip}}
              </div>
              <i class="zhk-list_rarrow"></i>
              <awesome-picker ref="licenseExpireStart" type="date" :textTitle="licenseExpireStart.textTitle"  :anchor="licenseExpireStart.anchor"  @confirm="(v)=>showPeriod('licenseExpire','licenseExpireStart',v)">
              </awesome-picker>
              <awesome-picker ref="licenseExpire"  :textTitle="licenseExpire.textTitle" :data="licenseExpire.data"  :anchor="licenseExpire.anchor" @cancel="()=>periodCancel('licenseExpireStart')" @confirm="(v)=>periodConfirm('licenseExpire',v,licenseExpire.data,'licenseExpireStart')">
              </awesome-picker>
            </div>
            <div class="form-item border-bt-left">
              <div class="label">是否三证合一</div>
              <div class="pick-value" @click="showPicker('licenseType')">{{this.formData.licenseType?showIdName(licenseType.data,this.formData.licenseType):licenseType.tip}}
              </div>
              <i class="zhk-list_rarrow"></i>
              <awesome-picker ref="licenseType" :textTitle="licenseType.textTitle" :data="getAwesomeData(licenseType.data)" :anchor="licenseType.anchor" @confirm="(v)=>handleConfirm('licenseType',v,licenseType.data)">
              </awesome-picker>
            </div>
          </div>
          <div  class="store-head ">
            <div class="tt">{{principalNameLb()+'身份证照片（正面）'}}</div>
            <div  class="ct border-bt">
                <div  class="store-head-box border-dashed" v-if="!formData.idcardImage.A" @click="chooseImg('idcardImageA','baidu_ocr_idcard_front')">
                  <img class="imgOpcity" :src="require('../../assets/images/up_bg_sa.png')" />
                  <span class="zhk-sczp"/>
                </div>
                <div class="store-head-box border-solid" v-else-if="formData.idcardImage.A" >
                  <img :src="repeatImgUrl(formData.idcardImage.A,'resize')" alt="" @click="showImg(formData.idcardImage.A)" />
                  <span class="zhk-sbylx" @click="delImage('idcardImageA')"></span>
                </div>
            </div>
          </div>
          <div  class="store-head ">
            <div class="tt">{{principalNameLb()+'身份证照片（背面）'}}</div>
            <div  class="ct border-bt">
                <div  class="store-head-box border-dashed" v-if="!formData.idcardImage.B" @click="chooseImg('idcardImageB','baidu_ocr_idcard_back')">
                  <img class="imgOpcity" :src="require('../../assets/images/up_bg_sb.png')" />
                  <span class="zhk-sczp"/>
                </div>
                <div class="store-head-box border-solid" v-else-if="formData.idcardImage.B" >
                  <img :src="repeatImgUrl(formData.idcardImage.B,'resize')" alt="" @click="showImg(formData.idcardImage.B)" />
                  <span class="zhk-sbylx" @click="delImage('idcardImageB')"></span>
                </div>
            </div>
          </div>
          <mt-field class="border-bt-left" :label="principalNameLb()+'姓名'" :placeholder="'请填写'+principalNameLb()+'姓名'" v-model="formData.businessOperatorName" :attr="{ maxlength: 10}"></mt-field>
          <mt-field class="border-bt-left" label="身份证号码" placeholder="请填写负责人身份证号码" v-model="formData.idcard" :attr="{ maxlength: 18}"></mt-field>
          <div class="form-item border-bt-left">
            <div class="label">身份证有效期</div>
            <div class="pick-value" @click="showPeriod('idcardValidStartDate')">{{this.formData.idcardValidStartDate && this.formData.idcardValidEndDate?this.formData.idcardValidStartDate + ' 至 ' + (this.formData.idcardValidEndDate == '29991231'?'长期':this.formData.idcardValidEndDate + '年'):idcardValidStartDate.tip}}
            </div>
            <i class="zhk-list_rarrow"></i>
            <awesome-picker ref="idcardValidStartDate" type="date" :textTitle="idcardValidStartDate.textTitle"  :anchor="idcardValidStartDate.anchor"  @confirm="(v)=>showPeriod('idcardValidEndDate','idcardValidStartDate',v)">
            </awesome-picker>
            <awesome-picker ref="idcardValidEndDate"  :textTitle="idcardValidEndDate.textTitle" :data="idcardValidEndDate.data"  :anchor="idcardValidEndDate.anchor" @cancel="()=>periodCancel('idcardValidStartDate')" @confirm="(v)=>periodConfirm('idcardValidEndDate',v,idcardValidEndDate.data,'idcardValidStartDate')">
            </awesome-picker>
          </div>
          <div class="form-item border-bt-left SMSVerification">
            <div class="label">邀请码</div>
            <div class="mint-cell-value">
              <inputClear warpClass="SMSVerification-input" type="txt"  v-model="formData.invitationCode" placeholder="请填写销售员工编号" minlength="6" maxlength="15"  />
              <a class="checkBtn"  @click="checkInvitationCode">验证</a>
            </div>
          </div>
          <div v-if="formData.bdMobile" class="form-item border-bt-left">
            <div class="label">验证的手机号</div>
            <div class="pick-value">{{formData.bdMobile}}</div>
          </div>
          <div class="form-item border-bt SMSVerification">
            <div class="label">短信验证码</div>
            <div class="mint-cell-value">
              <inputClear warpClass="SMSVerification-input" v-model="formData.msgCode" type="tel" placeholder="请填写短信验证码" maxlength="10" />
              <mt-button class="checkBtn"  v-if="!msgCodeOk"  @click="againSend">获取验证码</mt-button>
              <mt-button class="checkBtn" size="small"  disabled v-if="msgCodeOk">{{waitCount}}s 后重新发送</mt-button>
            </div>
          </div>
        </div>
        <div class="btn-box">
          <mt-button class="btn" type="primary" @click="submit">提交</mt-button>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
  import Vue from "vue";
  import customHeader from "../../components/header/header";
  import { Field, Toast, MessageBox } from "mint-ui";
  import AwesomePicker from "vue-awesome-picker";
  import jsBridge from "../../tools/jsBridge";
  import jsAuthority from "../../tools/jsAuthority.js";
  import config from "../../base/profile/config.json";
  import shopService from "../../js/shopService";
  import inputClear from "../../components/inputClear/inputClear";
  import CitysPicker from "vue-citys-picker";
  require("vue-citys-picker/dist/vue-citys-picker.css");
  import moment from "moment";
  Vue.use(AwesomePicker);
  Vue.component(Field.name, Field);
  export default {
    name: "editStore",
    data(){
      return{
        //头部文字
        header:'新增门店',
        //门店状态 1 新增 2 编辑
        editType:'1',
        //短信验证
        waitCount:60,
        msgCodeOk:false,//短信验证码发送成功
        //选择照片组件
        actions: [],
        chooseImgVisible:false,
        //门店区域拼接字段
        storeAreaName:'',
        storeAreaDefaultVal:"",
        dataArea: JSON.parse(JSON.stringify(addressUtility.getAreaList())),
        //所属类目拼接字段
        categorySplice:'',
        //表单数据
        formData:{
          shopId:'',//门店id
          supplierId:'',//自有商户id
          mainShopName:'',//主店名
          branchShopName:'',//分店名
          categoryId:'',//所属类目Id
          categoryName:'',//所属类目
          contactNumber:'',//门店电话
          provinceCode:'',//省code
          provinceName:'',//省name
          cityCode:'',//市code
          cityName:'',//市name
          districtCode:'',//区code
          districtName:'',//区name
          address:'',//门店地址
          desc:'',//门店简介
          invitationCode:'',//邀请码
          bdMobile:'',//邀请码返回的手机号
          msgCode:'',//短信验证码
          mainImage:[],//门头照
          checkoutImage:[],//收银照
          innerImage:[],//内景照
          shopType:'03',//商户类型
          companyName:'',//公司全称
          businessLicenseImage:'',//营业执照照片
          businessLicense:"",//营业执照注册号
          licenseRegisterAddress:"",//营业执照注册地址
          businessOperatorName:"",//法人姓名
          licenseExpireStart:'',//营业执照有效期起始时间
          licenseExpire:'',//营业执照有效期使用年限
          licenseType:'1',//是否三证合一
          idcardImage:{A:'',B:''},//身份证照正面
          idcard:'',//身份证号
          idcardValidStartDate:'',//身份证有效期起始时间
          idcardValidEndDate:'',//身份证有效期使用年限
          businessLicenseOcr:'',
          businessAddressOcr:'',
          companyNameOcr:'',
          licenseExpireStartOcr:'',
          licenseExpireOcr:'',
          businessOperatorNameOcr:'',
          idcardOcr:'',
          idcardNameOcr:'',
        },
        //所属类目
        category: {
          tip:"请选择",
          anchor: [],
          textTitle: "请选择所属类目",
          data: []
        },
        //商户类型
        shopType: {
          tip:"请选择",
          anchor: [0],
          textTitle: "请选择门店类型",
          data: [{key:'03',value:'企业商户'},{key:'02',value:'个体工商户'},{key:'01',value:'自然人'}]
        },
        //营业执照有效期
        licenseExpireStart:{
          tip:"请选择",
          anchor: [],
          textTitle: "营业执照有效期",
        },
        //营业执照有效期使用年限
        licenseExpire:{
          anchor: [],
          textTitle: "使用年限",
          data: [{key:'1',value:'1年'},{key:'2',value:'2年'},{key:'3',value:'3年'},{key:'4',value:'4年'},{key:'5',value:'5年'},{key:'6',value:'6年'},{key:'7',value:'7年'},{key:'8',value:'8年'},{key:'9',value:'9年'},{key:'10',value:'10年'},{key:'20',value:'20年'},{key:'30',value:'30年'},{key:'40',value:'40年'},{key:'50',value:'50年'},{key:'60',value:'60年'},{key:'70',value:'70年'},{key:'29991231',value:'长期'}]
        },
        //是否三证合一
       licenseType:{
         tip:"请选择",
         anchor: [0],
         textTitle: "是否三证合一",
         data: [{key:'1',value:'是'},{key:'0',value:'不是'}]
       },
       //身份证有效期
       idcardValidStartDate:{
         tip:"请选择",
         anchor: [],
         textTitle: "身份证有效期",
       },
       //身份证有效期使用年限
       idcardValidEndDate:{
         anchor: [],
         textTitle: "使用年限",
         data: [{key:'5',value:'5年'},{key:'10',value:'10年'},{key:'20',value:'20年'},{key:'29991231',value:'长期'}]
       }
     }
    },
    created: function() {
      const query = this.$route.query;
      const editType = query.type || '1';
      const shopId = query.id || '';
      this.editType = editType;
      this.formData.shopId = shopId;
  		if(editType == '1'){
  			this.header = '新增门店'
  		}
      if(editType == '2'){
        this.header = '编辑门店'
      }
    },
    mounted(){
      this.loadCategory();
    },
    methods:{
      storeAreaShow(citys) {
        this.$refs["citys"].open();
      },
      storeAreaConfirm(values) {
        this.formData.provinceName = values[0].name;
        this.formData.cityName = values[1].name;
        this.formData.districtName = values[2].name;
        this.formData.provinceCode = values[0].value;//省code
        this.formData.cityCode = values[1].value;//市code
        this.formData.districtCode = values[2].value;//区code
        this.storeAreaName = values[0].name + "-" + values[1].name + "-" + values[2].name;

      },
      repeatImgUrl(url,resize){
        if(resize){
          return CommonUtil.imgUrlFormate(url,config.previewUrlPrefix)+"?"+CommonUtil.imgUrlResize('m_fill','230','360');
        }
        return CommonUtil.imgUrlFormate(url,config.previewUrlPrefix)
      },
      //请求*******************************
      //所属类目数据请求
      loadCategory() {
        this.ajax({
          type: "get",
          url: "/newapp/shop/queryCategory.do"
        })
          .then((response) =>{
            if (response && response.success) {
              var categoryList = this.getResetCategory(response.resultObject, 0);
              this.category.data = categoryList;
              if(this.editType == '2'){
                this.loadShopInfo()
              }
            } else {
              Toast("加载所属类目失败");
            }
          })
          .catch((err) =>{
            // MessageBox.alert("获取分类异常，请稍候重试").then(action => {
            //   this.$router.back();
            // });
          });
      },
      changeMoment(date){
        return moment(date).format('YYYY-MM-DD')
      },
      loadShopInfo() {
        let shopId = this.$route.query.id;
        this.ajax({
          url: "/app/shopNew/getShopDetail.do?shopId=" + shopId,
          type: "get",
          controlLoading: true
        })
          .then((res) => {
            if (res.success) {
                const data = res.resultObject;
                for(let key in data){
                  for(let keys in this.formData){
                    if(key == keys){
                      this.formData[keys] = data[key]
                    }
                  }
                }
                this.formData.licenseType = data.licenseType.toString();
                if(!this.formData.idcardImage){
                  this.formData.idcardImage = {A:'',B:''}
                }
                this.formData.licenseExpireStart = this.formData.licenseExpireStart?this.changeMoment(this.formData.licenseExpireStart):'';
                this.formData.idcardValidStartDate = this.formData.idcardValidStartDate?this.changeMoment(this.formData.idcardValidStartDate):'';
                this.categorySplice = (data.categoryLevel1 || '') +  (data.categoryLevel2?' - ' + data.categoryLevel2:'') + (data.categoryLevel3?' - ' + data.categoryLevel3:'');
                if (!this.formData.provinceCode || !this.formData.cityCode || !this.formData.districtCode || !this.formData.provinceName || !this.formData.cityName || !this.formData.districtName) {
                  this.storeAreaName = '';
                  this.storeAreaDefaultVal = '';
                }else{
                  this.storeAreaDefaultVal = [{name:this.formData.provinceName,value:this.formData.provinceCode},{name:this.formData.cityName,value:this.formData.cityCode},{name:this.formData.districtName,value:this.formData.districtCode}];
                  this.storeAreaName = (data.provinceName || '') +  (data.cityName?' - ' + data.cityName:'') + (data.districtName?' - ' + data.districtName:'');
                };
              } else {
                Toast("加载门店信息失败");
              }
          })
          .catch((err) =>{
            // MessageBox.alert("获取门店信息异常，请稍候重试").then(action => {
            //   this.$router.back();
            // });
          });
      },
      //上传图片到服务器
      doUploadPic: function(type, result, ocr) {
        var serverUrl = window.APP.serverUrl;
        var url = serverUrl + "/newapp/img/uploadShopImg.do";
        let params = {};
        if(ocr == 'baidu_ocr_business_license'){
          url = serverUrl + "/newapp/imgManage/uploadOCRImage.do";//ocr识别上传地址
          params.code = 'ocr_business_license';
          params.uploadType = '03'
        }
        //身份证正面ocr
        if(ocr == 'baidu_ocr_idcard_front'){
          url = serverUrl + "/newapp/imgManage/uploadOCRImage.do";//ocr识别上传地址
          params.code = 'ocr_idcard';
          params.cardSide = 'front';
          params.uploadType = '01';
        }
        //身份证反面ocr
        if(ocr == 'baidu_ocr_idcard_back'){
          url = serverUrl + "/newapp/imgManage/uploadOCRImage.do";//ocr识别上传地址
          params.code = 'ocr_idcard';
          params.cardSide = 'back';
          params.uploadType = '02';
        }

        jsBridge.doUploadPic(
          {
            url: url,
            file: result.resultObject,
            data: params,
            //限制图片压缩后的大小最大1.2M
            compress: { sizeLimit: "1", unit: "M" }
          },
          (result) =>{
            //以下为正常的业务逻辑
            if (result && result.success) {
              var uploadResult = result.resultObject;
              if (uploadResult && uploadResult.imageUrl) {
                var url = uploadResult.imageUrl;
                if(type == 'idcardImageA'){
                  this.formData.idcardImage.A = url;
                }
                if(type == 'idcardImageB'){
                  this.formData.idcardImage.B = url;
                }
                if(typeof(this.formData[type]) == 'string'){
                  this.formData[type] = url;
                }
                if(typeof(this.formData[type]) == 'object'){
                  this.formData[type].push(url);
                }
              }
              if(ocr){
                if(uploadResult.ocrSuccess&&Object.keys(JSON.parse(uploadResult.ocrResult)).length != 0){
                  let ocrData = JSON.parse(uploadResult.ocrResult);//ocr识别出的数据
                      const formData = this.formData;//表单填写的数据
                      //识别营业执照
                      if(ocr == 'baidu_ocr_business_license'){
                        let flag = false;
                        let messageText = "";
                        //公司全称
                        if(!formData.companyName || formData.companyName == ocrData.name){
                          this.formData.companyName = ocrData.name;
                        }else{
                          if(ocrData.name){
                            flag = true;
                            messageText = messageText + "<div style='display:flex'><div>" + "公司全称：</div><div style='flex:1;word-wrap:break-word;word-break:break-all'>"+ocrData.name+"</div></div>";
                          }
                        }
                        // //法人 - 经营者 - 申请人 姓名
                        // if(!formData.businessOperatorName || formData.businessOperatorName == ocrData.person){
                        //   this.formData.businessOperatorName = ocrData.person;
                        // }else{
                        //   flag = true;
                        //   messageText = messageText + this.principalNameLb() + '姓名'+ ocrData.person+'<br/>';
                        // }
                        //营业执照注册号
                        if(!formData.businessLicense || formData.businessLicense == ocrData.regNum){
                          this.formData.businessLicense = ocrData.regNum;
                        }else{
                          if(ocrData.regNum){
                            flag = true;
                            messageText = messageText + "<div style='display:flex'><div>" + "营业执照注册号：</div><div style='flex:1;word-wrap:break-word;word-break:break-all'>"+ocrData.regNum+"</div></div>";
                          }
                        }
                        // //公司类型
                        // if(!formData.shopType || formData.shopType == ocrData.type){
                        //   this.formData.shopType = ocrData.type;
                        // }else{
                        //   flag = true;
                        //   messageText = messageText +'商户类型：'+ ocrData.type+'<br/>';
                        // }
                        //营业执照有效期
                        let establishDate = ocrData.establishDate?ocrData.establishDate:'';//ocr返回的是‘20190101’转换成‘2019-01-02’格式
                        let validPeriod = ocrData.validPeriod?ocrData.validPeriod:'';
                        const startYear = moment(establishDate.replace(/-/g,"/")).format('YYYY');
                        const endYear = moment(validPeriod.replace(/-/g,"/")).format('YYYY');
                        let difference = endYear - startYear;
                        if(difference <= 0){
                          validPeriod ='';
                        };
                        if((!formData.licenseExpireStart || formData.licenseExpireStart == establishDate) && (!formData.licenseExpire || formData.licenseExpire == (validPeriod == '2999-12-31'?'29991231':validPeriod ))){
                          if(establishDate && validPeriod){
                            this.formData.licenseExpireStart = establishDate;//起始时间
                            if(difference > 70){
                              this.formData.licenseExpire = '29991231';//结束时间
                              validPeriod = '29991231';
                            }else{
                              this.formData.licenseExpire = difference;
                              validPeriod = difference;
                            }
                          }else{
                            this.formData.licenseExpireStart = '';//起始时间
                            this.formData.licenseExpire = '';//结束时间
                          }
                        }else{
                          if(establishDate && validPeriod){
                            flag = true;
                            if(difference > 70){
                              validPeriod = '29991231';//结束时间
                            }else{
                              validPeriod = difference;
                            }
                            messageText = messageText + "<div style='display:flex'><div>" + "营业执照有效期：</div><div style='flex:1;word-wrap:break-word;word-break:break-all'>"+ establishDate + " 至 " + (validPeriod == '29991231'?'长期':difference+'年') +"</div></div>";
                          }
                        }
                        //营业执照注册地址
                        if(!formData.licenseRegisterAddress || formData.licenseRegisterAddress == ocrData.address){
                          this.formData.licenseRegisterAddress = ocrData.address;
                        }else{
                          if(ocrData.address){
                            flag = true;
                            messageText = messageText + "<div style='display:flex'><div>" + "营业执照注册地址：</div><div style='flex:1;word-wrap:break-word;word-break:break-all'>"+ocrData.address+"</div></div>";
                          }
                        }
                        this.formData.businessLicenseOcr = ocrData.regNum || '';//注册号
                        this.formData.companyNameOcr = ocrData.name || '';//公司名称
                        this.formData.licenseExpireStartOcr = establishDate || '';//公司注册日期
                        this.formData.licenseExpireOcr = validPeriod;//营业期限终止日期
                        this.formData.businessOperatorNameOcr = ocrData.person || '';//公司法人
                        this.formData.businessTypeOcr = ocrData.type || '';//公司类型
                        this.formData.businessAddressOcr = ocrData.address || '';//公司地址
                        this.formData.businessCapitalOcr = ocrData.capital || '';//注册资本
                        this.formData.businessOcr = ocrData.business || '';//经营范围
                        if(flag){
                          this.checkOrcReturn(messageText,'baidu_ocr_business_license');
                        }
                      };
                      //身份证正面
                      if(ocr == 'baidu_ocr_idcard_front'){
                        let flag = false;
                        let messageText = "";
                        if(!formData.idcard || formData.idcard == ocrData.num){
                          this.formData.idcard = ocrData.num;
                        }else{
                          if(ocrData.num){
                            flag = true;
                            messageText = messageText + "<div style='display:flex'><div>" + "身份证号：</div><div style='flex:1;word-wrap:break-word;word-break:break-all'>"+ ocrData.num +"</div></div>";
                          }
                        }
                        if(!formData.businessOperatorName || formData.businessOperatorName == ocrData.name){
                          this.formData.businessOperatorName = ocrData.name;
                        }else{
                          if(ocrData.name){
                            flag = true;
                            messageText = messageText + "<div style='display:flex'><div>" + this.principalNameLb() + "姓名：</div><div style='flex:1;word-wrap:break-word;word-break:break-all'>"+ ocrData.name +"</div></div>";
                          }
                        }
                        this.formData.idcardOcr = ocrData.num || '';//身份证号
                        this.formData.idcardNameOcr = ocrData.name || '';//姓名
                        this.formData.idcardNationalityOcr = ocrData.nationality || '';//民族
                        this.formData.idcardSexOcr = ocrData.sex || '';//性别
                        this.formData.idcardBirthOcr = ocrData.birth || '';//出生日期
                        this.formData.idcardAddressOcr = ocrData.address || '';//地址信息
                        if(flag){
                          this.checkOrcReturn(messageText,'baidu_ocr_idcard_front');
                        }
                      };
                      //身份证反面
                      if(ocr == 'baidu_ocr_idcard_back'){

                        let flag = false;
                        let messageText = "";
                        //身份证有效期
                        let startDate = ocrData.startDate?ocrData.startDate:'';//ocr返回的是‘20190101’转换成‘2019-01-02’格式
                        let endDate = ocrData.endDate?ocrData.endDate:'';
                        const startYear = moment(startDate.replace(/-/g,"/")).format('YYYY');
                        const endYear = moment(endDate.replace(/-/g,"/")).format('YYYY');
                        let difference = endYear - startYear;
                        if(difference <=0){
                          endDate = '';
                        };
                        let differenceFlag = false;
                        this.idcardValidEndDate.data.map((item)=>{
                          if(difference <= 20){
                            if(item.key == difference){
                              differenceFlag = true;
                            }
                          }else{
                            differenceFlag = true;
                          }
                        });
                        if(!differenceFlag){
                          endDate = '';
                        };
                      
                        if((!formData.idcardValidStartDate || formData.idcardValidStartDate == startDate) && (!formData.idcardValidEndDate || formData.idcardValidEndDate == (endDate == '2999-12-31'?'29991231':endDate ))){
                          if(startDate && endDate){
                            this.formData.idcardValidStartDate = startDate;//起始时间
                            if(difference > 20){
                              this.formData.idcardValidEndDate = '29991231';//结束时间
                              endDate = '29991231';
                            }else{
                              this.formData.idcardValidEndDate = difference;
                              endDate = difference;
                            }
                          }else{
                            this.formData.idcardValidStartDate = '';//起始时间
                            this.formData.idcardValidEndDate = '';//结束时间
                          }
                        }else{
                          if(startDate && endDate){
                            flag = true;
                            if(difference > 20){
                              endDate = '29991231';//结束时间
                            }else{
                              endDate = difference;
                            }
                            messageText = messageText + "<div style='display:flex'><div>" + "身份证有效期：</div><div style='flex:1;word-wrap:break-word;word-break:break-all'>"+ startDate + " 至 " + (endDate == '29991231'?'长期':difference+'年') +"</div></div>";
                          }
                        };
                        this.formData.idcardValidStartDateOcr = startDate || '';//有效期起始时间
                        this.formData.idcardValidEndDateOcr = endDate;//有效期结束时间
                        this.formData.idcardIssueOcr = ocrData.issue || '';//签发机关
                        if(flag){
                          this.checkOrcReturn(messageText,'baidu_ocr_idcard_back');
                        }
                      };
                }else{
                  MessageBox({
                    title: '提示',
                    message: '无法识别图片中的内容，通常是由于图片模糊不清造成，建议更换清晰图片',
                    confirmButtonText:'知道了'
                  });
                }
              }

              return;
            }
            var msg = result.msg || "上传失败";
            Toast(msg);
          },
          function(result) {

          }
        );
      },
      //数据处理*******************************
      //所属类目数据处理
      getResetCategory(list, dept) {
        //重置门店分类格式
        var ary = [];
        var currentDept = dept + 1;
        for (var i = 0; i < list.length; i++) {
          var item = {
            key: list[i].categoryId,
            value: list[i].name
          };
          //默认选中逻辑处理
          var oldLen = this.category.anchor.length;

          if (currentDept < 3) {
            var children = this.getResetCategory(list[i].children, currentDept);
            if (children) {
              item.children = children;
            }
            //设置默认选中的数组
            var newLen = this.category.anchor.length;
            if (newLen > oldLen) {
              this.category.anchor[this.category.anchor.length] = i;
            }
          }
          if (currentDept === 1) {
            if (item.children.length === 0) {
              item.children[item.children.length] = { children: [] };
            }
          }
          ary[ary.length] = item;
          //设置默认选中的数组
          if (list[i].categoryId == this.categoryId) {
            this.category.anchor[this.category.anchor.length] = i;
          }
        }
        return ary;
      },
      //检查邀请码
      checkInvitationCode(){
        this.formData.bdMobile = '';
        this.formData.msgCodeOk = false;
        this.formData.msgCode = '';
        if(this.formData.invitationCode.length == 0){
          Toast("请输入邀请码");
        }else if(this.formData.invitationCode.length<6&&this.formData.invitationCode.length>0){
          Toast("请输入有效的邀请码");
        }else{
          let url = '/app/shop/checkInvitationCode.do?invitationCode='+this.formData.invitationCode;
          this.ajax({
          type: "get",
          url: url
        }).then((response)=>{
          var msg = response.msg || "验证邀请码失败，请稍后重试";
          if (response && response.success) {
            this.formData.bdMobile = response.resultObject;
            Toast("邀请码正确，准备短信验证"+this.formData.bdMobile);
          }else{
            Toast(msg);
          }
        });
        }
      },

      //页面交互*******************************
      //点击请选择弹出选择项
      //选择图片的方式本地相册或者拍照,如果传ocr需要进行ocr图像识别
      chooseImg: function(type,ocr) {
        var _this = this;
        _this.actions = [
          {
            name: "拍照",
            method: function() {
              jsBridge.selectPicture(
                { options: "拍照", noCrop: true, compress: { sizeLimit: "1", unit: "M" }},
                function(result) {
                    _this.doUploadPic(type, result, ocr);
                },
                function(result) {

                }
              );
            }
          },
          {
            name: "选择图片",
            method: function() {
              jsBridge.selectPicture(
                {
                  options: "选择图片",
                  noCrop: true,
                  compress: { sizeLimit: "1", unit: "M" }
                },
                function(result) {
                    _this.doUploadPic(type, result, ocr);
                },
                function(result) {

                }
              );
            }
          }
        ];

        this.chooseImgVisible = true;
        return false;
      },

      //删除图片
      delImage(key) {
        if(key == 'idcardImageA'){
          this.formData.idcardImage.A = '';
          return
        }
        if(key == 'idcardImageB'){
          this.formData.idcardImage.B = '';
          return
        }
        if(typeof(this.formData[key]) == 'string'){
          this.formData[key] = "";
          return
        }
        if(typeof(this.formData[key]) == 'object'){
          this.formData[key].splice(0,1);
          return
        }
      },
      //根据枚举展示字段名字
      showIdName(data,key){
        let name ='';
        for(let i =0; i<data.length;i++){
          if(data[i].key == key){
            return data[i].value;
          }
        }
        return ''
      },
      //处理ocr返回的日期格式
      dealOcrDate(date){
        if(date){
          let newstr="";
          newstr = date.substring(0,4) + '-' + date.substring(4,6) + '-' + date.substring(6,date.length);
          return newstr
        }
        return ''
      },
      getIdToIndex(data,indexArr){
        const newArr = [];
        for(let i=0;i<indexArr.length;i++){
          if(indexArr[i].value){
            newArr.push(indexArr[i])
          }
        }
        const lev = newArr.length;
        let n = 0;
        let res = '';
        const getData =(datas)=>{
          n=n+1;
            if(n == lev){
              debugger
              res =  datas[newArr[n-1].index];
            }else{
              getData(datas[newArr[n-1].index].children);

            }

        }
        getData(data)
        return res;
      },
      //根据value获取key
      getId(data,val,lev){
        if(lev == 1){
          for(let i =0; i<data.length;i++){
            if(data[i].value == val){
              return data[i].key || data[i].id;
            }
          }
        }
        if(lev == 2){
          for(let i =0; i<data.length;i++){
            for(let j =0; j<data[i].children.length;j++){
              let lev2Data =  data[i].children[j]
              if(lev2Data.value == val){
                return lev2Data.key || lev2Data.id;
              }
            }
          }
        }
        if(lev == 3){
          for(let i =0; i<data.length;i++){
            for(let j =0; j<data[i].children.length;j++){
              let lev2Data =  data[i].children[j]
              for(let n =0; n<lev2Data.children.length;n++){
                let lev3Data =  lev2Data.children[n];
                if(lev3Data.value == val){
                  return lev3Data.key || lev3Data.id;
                }
              }
            }
          }
        }
        return
      },
      getAwesomeData(data){
        let newData =[[]];
        data.map((item)=>{
          newData[0].push(item.value)
        });
        return newData
      },
      showPicker(ref) {
        this.$refs[ref].show();
      },
      //弹窗选择回掉赋值
      handleConfirm(key,v,data){
        //商户类型切换清空下面对应数据
        if(key == 'shopType'){
          this.formData.companyName = '';//公司全称
          this.formData.businessLicenseImage = '';//营业执照照片
          this.formData.businessLicense = '';//营业执照注册号
          this.formData.businessOperatorName = '';//法人姓名
          this.formData.licenseExpireStart = '';//营业执照有效期起始时间
          this.formData.licenseExpire = '';//营业执照有效期使用年限
          this.formData.licenseType = '1';//是否三证合一
          this.formData.idcardImage = {A:'',B:''};//身份证照正面
          this.formData.idcard = '';//身份证号
          this.formData.idcardValidStartDate = '';//身份证有效期起始时间
          this.formData.idcardValidEndDate = '';//身份证有效期使用年限
          this.formData.businessLicenseOcr =  '';//注册号
          this.formData.companyNameOcr =  '';//公司名称
          this.formData.licenseExpireStartOcr = '';//公司注册日期
          this.formData.licenseExpireOcr = '';//营业期限终止日期
          this.formData.businessOperatorNameOcr = '';//公司法人
          this.formData.businessTypeOcr = '';//公司类型
          this.formData.businessAddressOcr = '';//公司地址
          this.formData.businessCapitalOcr = '';//注册资本
          this.formData.businessOcr = '';//经营范围
          this.formData.idcardOcr = '';//身份证号
          this.formData.idcardNameOcr = '';//姓名
          this.formData.idcardNationalityOcr = '';//民族
          this.formData.idcardSexOcr = '';//性别
          this.formData.idcardBirthOcr = '';//出生日期
          this.formData.idcardAddressOcr = '';//地址信息
          this.formData.idcardValidStartDateOcr = '';//有效期起始时间
          this.formData.idcardValidEndDateOcr = '';//有效期结束时间
          this.formData.idcardIssueOcr = '';//签发机关
        };
        if(key == 'category'){
          this.categorySplice = "";
          let n =0;
          for(let i =0;i<v.length;i++){
            if(v[i].value){
              n = n+1;
              this.formData.categoryName = v[i].value;
              this.categorySplice = this.categorySplice + (i != 0?'-':'') + v[i].value;
            }
          }
            this.formData.categoryId = this.getIdToIndex(data,v).key;
            this[key].anchor = [v[0].index,v[1].index,v[2].index];
          return
        }
        if(key == 'storeArea'){
          this.storeAreaName = "";
          for(let i =0;i<v.length;i++){
            if(v[i].value){
              this.storeAreaName = this.storeAreaName + (i != 0?'-':'') + v[i].value;//拼接门店区域
            }
          };
          this.formData.provinceName = v[0].value || '';
          this.formData.cityName = v[1].value || '';
          this.formData.districtName = v[2].value || '';
          this.formData.provinceCode = this.getId(data,v[0].value,1) || '';//省code
          this.formData.cityCode = this.getId(data,v[1].value,2) || '';//市code
          this.formData.districtCode = this.getId(data,v[2].value,3) || '';//区code
          this[key].anchor = [v[0].index,v[1].index,v[2].index];
          return
        }
        this[key].anchor = [v[0].index];
        this.formData[key] = this.getId(data,v[v.length-1].value,v.length);
      },
      //有效期弹窗
      showPeriod(key,label,v){
        this.$refs[key].show();
        if(v){
          //拼接日期
          let year = v[0].value.substring(0,v[0].value.length-1);
          let mouth = v[1].value.substring(0,v[1].value.length-1);
          let days = v[2].value.substring(0,v[2].value.length-1);
          this.formData[label] = moment(year +'/' + mouth + '/' +days).format('YYYY-MM-DD');
        }
      },
      //选择使用年限
      periodConfirm(key,v,data,startTime){
        let diffVal = this.getId(data,v[0].value,1);
        this.formData[key] = diffVal
      },
      //不选使用年限清空有效期
      periodCancel(key){
        this.formData[key] = "";
      },
      //h5调native后退
      handleBack() {
        this.$router.push({ path: "/storeManage",query: CommonUtil.concatSessionId({}) });
      },
      // 60s倒计时
      countDown() {
          this.waitCount = 60;
          this.timer = setInterval(() => {
            if (this.waitCount > 0 && this.waitCount <= 60) {
              this.waitCount--;
            } else {
              this.msgCodeOk = false;
              clearInterval(this.timer);
            }
          }, 1000);
      },
      // 发送验证码
      againSend() {
        if(this.formData.bdMobile==''){
          Toast("请先验证邀请码获取验证手机号")
        }else{
          this.sendCode();
        }
      },
      // 发送短信
      sendCode() {
        let url = '/app/shop/sendMsgCode.do?invitationCode='+this.formData.invitationCode;
          this.ajax({
          type: "get",
          url: url
        }).then((response)=>{
          var msg = response.msg || "获取验证码失败，请稍后重试";
          if (response && response.success) {
              Toast("验证码发送成功");
              this.msgCodeOk = true;
              this.countDown();
            }else{
              Toast(msg);
            }
        });
      },
      //验证是否为空
      checkIsEmpty(name, str) {
        if (
          typeof str !== "string" ||
          str === "" ||
          str.replace(/^\s+|\s+$/gm, "") === ""
        ) {
          Toast("请输入" + name);
          return true;
        }
        return false;
      },
      principalNameLb(){
          switch(this.formData.shopType){
            case '03':
            return '法人';
            break;
            case '02':
            return '经营者';
            break;
            case '01':
            return '申请人';
            break;
            default:
            return '法人'
          }
      },
      //ocr图像识别
      checkOrcReturn(messageText,ocr){
        MessageBox({
          title: '是否覆盖已有内容',
          message: `<div style="text-align:left">${messageText}</div>`,
          confirmButtonText:'是',
          cancelButtonText:'否',
          showCancelButton: true
        }).then((action) => {
          if(action == 'confirm'){
            if(ocr == 'baidu_ocr_business_license'){
              this.formData.businessLicense = this.formData.businessLicenseOcr || '';//注册号
              this.formData.licenseRegisterAddress = this.ocrData.businessAddressOcr || '';//营业执照注册地址
              this.formData.companyName = this.formData.companyNameOcr || '';//公司名称
              if(this.formData.licenseExpireStartOcr && this.formData.licenseExpireOcr){
                this.formData.licenseExpireStart = this.formData.licenseExpireStartOcr || '';//公司注册日期
                this.formData.licenseExpire = this.formData.licenseExpireOcr || '';//营业期限终止日期
              }
              //this.formData.businessOperatorName = this.formData.businessOperatorNameOcr || '';//公司法人
            }
            if(ocr == 'baidu_ocr_idcard_front'){
              this.formData.idcard = this.formData.idcardOcr || '';//身份证号
              this.formData.businessOperatorName = this.formData.idcardNameOcr || '';
            }
            if(ocr == 'baidu_ocr_idcard_back'){
              if(this.formData.idcardValidStartDateOcr && this.formData.idcardValidEndDateOcr){
                this.formData.idcardValidStartDate = this.formData.idcardValidStartDateOcr || '';//有效期起始时间
                this.formData.idcardValidEndDate = this.formData.idcardValidEndDateOcr || '';//有效期结束时间
              }
            }
          }

        })
      },
      showImg: function(url) {
        let urlArr = [];
        urlArr.push(this.repeatImgUrl(url))
        try {
          jsBridge.viewPicture(
            { files: urlArr},
            function(params) {

            }
          );
        } catch (e) {
          Toast("预览失败");
        }
      },
      //提交前对所有字段的校验
      verify(){
        if(this.checkIsEmpty("门店名称", this.formData.mainShopName)){
          return false;
        };
        if(!/^[\u4e00-\u9fa50-9a-zA-Z()（）]+$/.test(this.formData.mainShopName)) {
          Toast("门店名称不允许包含特殊符号");
          return false;
        };
        if(this.formData.branchShopName){
          if(!/^[\u4e00-\u9fa50-9a-zA-Z()（）]+$/.test(this.formData.branchShopName)) {
            Toast("分店名称不允许包含特殊符号");
            return false;
          };
        }
        if (!this.categorySplice) {
          Toast("请选择所属类目");
          return false;
        };
        if (this.checkIsEmpty("门店电话", this.formData.contactNumber)) {
          return false;
        };
        if (!/^1[0-9]{10}$/.test(this.formData.contactNumber)) {
          Toast("请填写有效手机号");
          return false;
        }
        if (!this.formData.provinceCode || !this.formData.cityCode || !this.formData.districtCode || !this.formData.provinceName || !this.formData.cityName || !this.formData.districtName) {
          Toast("请选择门店区域");
          return false;
        };
        if (this.checkIsEmpty("门店地址", this.formData.address)) {
          return false;
        };
        if (this.checkIsEmpty("邀请码", this.formData.invitationCode)) {
          return false;
        };
        if (this.checkIsEmpty("短信验证码", this.formData.msgCode)) {
          return false;
        };
        if (!this.formData.mainImage) {
          Toast("请上传门头照");
          return false;
        };
        if (!this.formData.checkoutImage) {
          Toast("请上传收银台照");
          return false;
        };
        if (!this.formData.innerImage) {
          Toast("请上传内景照");
          return false;
        };
        if (!this.formData.shopType) {
          Toast("请选择商户类型");
          return false;
        };
        if (this.checkIsEmpty("公司全称", this.formData.companyName)) {
          return false;
        };
        if(!/^[\u4e00-\u9fa50-9a-zA-Z()（）]+$/.test(this.formData.companyName)) {
          Toast("公司全称不允许包含特殊符号");
          return false;
        };
        if(!/^(?!\d+$)[\d\u4e00-\u9fa50-9a-zA-Z()（）]+$/.test(this.formData.companyName)) {
          Toast("公司全称不能是纯数字");
          return false;
        };
        if (this.formData.shopType == '03' || this.formData.shopType == '02') {
          if(!this.formData.businessLicenseImage){
            Toast("请上传营业执照照片");
            return false;
          }
          if(this.checkIsEmpty("营业执照注册地址", this.formData.licenseRegisterAddress)){
            return false;
          };
          if(this.checkIsEmpty("营业执照注册号", this.formData.businessLicense)){
            return false;
          };
          if(!/^[0-9a-zA-Z]+$/.test(this.formData.businessLicense)) {
            Toast("营业执照注册号不允许包含特殊符号");
            return false;
          };
          if(!this.formData.licenseExpire&&!this.formData.licenseExpire){
            Toast("请选择营业执照有效期");
            return false;
          };
          if (!this.formData.licenseType) {
            Toast("请选择是否三证合一");
            return false;
          };
        };
        if (!this.formData.idcardImage.A) {
          Toast("请上传身份证照片正面");
          return false;
        };
        if (!this.formData.idcardImage.B) {
          Toast("请上传身份证照片反面");
          return false;
        };
        if (!this.formData.businessOperatorName) {
          Toast("请填写"+this.principalNameLb()+'姓名');
          return false;
        };
        if (!/^[\u4e00-\u9fa50-9a-zA-Z.·]+$/.test(this.formData.businessOperatorName)) {
          Toast(this.principalNameLb()+'姓名不允许包含特殊字符');
          return false;
        };
        if(!this.formData.idcardValidStartDate&&!this.formData.idcardValidEndDate){
          Toast("请选择身份证有效期");
          return false;
        };
        if (!this.formData.idcard) {
          Toast("请输入身份证号码");
          return false;
        }
        var test = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/;
        var reg = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
        if (!reg.test(this.formData.idcard) && !test.test(this.formData.idcard)) {
          Toast("请输入正确的身份证号码");
          return false;
        }
        return true
      },
      submitAjax(){
        let sumbData = Object.assign({},this.formData);
        sumbData.licenseExpireStart = moment(sumbData.licenseExpireStart).valueOf();
        sumbData.idcardValidStartDate = moment(sumbData.idcardValidStartDate).valueOf();
        let url = '/newapp/shop/addSelfShop.do';
        if(this.editType == '2'){
          url = '/newapp/shop/modifySelfShop.do'
        }
          this.ajax({
          type: "post",
          url: url,
          data:sumbData
        }).then((response)=>{
          if (response && response.success) {
            const shopId = response.resultObject.shopId || this.$route.query.id;
            const AuditStatus = response.resultObject.auditStatus;
            const editType = this.editType;
            this.$router.push({ path: "/storeManage/editStore/editStoreSuccess",query: CommonUtil.concatSessionId({shopId:shopId,AuditStatus:AuditStatus,editType:editType})});
            }else{
            Toast(response.msg)
            }
        });
      },
      //提交表单
      submit(){
        //校验字段
        if(!this.verify()){
          return
        };
        if(this.formData.shopType != '01'){
          if(this.formData.idcardNameOcr&&this.formData.businessOperatorNameOcr){
            if(this.formData.businessOperatorName != this.formData.idcardNameOcr || this.formData.businessOperatorName != this.formData.businessOperatorNameOcr || this.formData.businessOperatorNameOcr!=this.formData.idcardNameOcr){
              MessageBox({
                title: '提示',
                message: '页面填写的法人/经营者/申请人姓名与营业执照、身份证识别出的姓名不一致，请确认无误后再提交',
                confirmButtonText:'继续提交',
                cancelButtonText:'取消',
                showCancelButton: true
              }).then((action) => {
                if(action == 'confirm'){
                  this.submitAjax();
                }
              })
            }else{
              this.submitAjax();
            }
          }else{
            MessageBox({
              title: '提示',
              message: '页面填写的法人/经营者/申请人姓名与营业执照、身份证识别出的姓名不一致，请确认无误后再提交',
              confirmButtonText:'继续提交',
              cancelButtonText:'取消',
              showCancelButton: true
            }).then((action) => {
              if(action == 'confirm'){
                this.submitAjax();
              }
            })
          }
        }else{
          if(this.formData.idcardNameOcr){
            if(this.formData.businessOperatorName != this.formData.idcardNameOcr ){
              MessageBox({
                title: '提示',
                message: '页面填写的法人/经营者/申请人姓名与营业执照、身份证识别出的姓名不一致，请确认无误后再提交',
                confirmButtonText:'继续提交',
                cancelButtonText:'取消',
                showCancelButton: true
              }).then((action) => {
                if(action == 'confirm'){
                  this.submitAjax();
                }
              })
            }else{
              this.submitAjax();
            }
          }else{
            MessageBox({
              title: '提示',
              message: '页面填写的法人/经营者/申请人姓名与营业执照、身份证识别出的姓名不一致，请确认无误后再提交',
              confirmButtonText:'继续提交',
              cancelButtonText:'取消',
              showCancelButton: true
            }).then((action) => {
              if(action == 'confirm'){
                this.submitAjax();
              }
            })
          }
        }

      }
    },
    components: {
      customHeader,
      inputClear,
      CitysPicker
    }
  }
</script>
<style lang='scss' scoped>
@import "editStore";
</style>
<style lang='scss'>
@import "../../style/public";
.SMSVerification{
  .mint-cell-value{
    flex:3;
    justify-content: center;
    .input-clear-wrap{
      flex:1;
    }
    .checkBtn{
      @include remCalc(font-size, 32);
      @include remCalc(padding, 5,0,5,0);
      @include remCalc(padding-left, 12);
      @include remCalc(margin-left, 12);
      height:auto;
      line-height: 1;
      color: $color-red;
      border:0;
      box-shadow: 0 0 1px #fff;
      background: #fff;
      border-radius: 0;
      @include remCalc(border-left, 1px solid #dddddd);
    }
  }
}
.editStore {
  .btn-box {
    .mint-button--primary {
      background-color: $color-red;
    }
  }
}
// .input-clear-wrap{
//   @include remCalc(width, 200,!important);
// }
.SMSVerification-input {
  text-align: right !important;
  @include remCalc(padding, 20,0);
  @include remCalc(font-size, 28,!important);
  // @include remCalc(width, 200,!important);

}
</style>
